home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / shell / point / src / window.c < prev   
Encoding:
C/C++ Source or Header  |  1994-11-16  |  1.9 KB  |  94 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <winb.h>
  6. #include <te.h>
  7. #include <fntb.h>
  8. #include <gui.h>
  9. #include <mos.h>
  10.  
  11. int    windowId = -1 ;
  12. int    xMessageId = -1 ;
  13. int    yMessageId = -1 ;
  14. int xPointMessageId = -1 ;
  15. int yPointMessageId = -1 ;
  16.  
  17. /*    initDataMWINDOW:NULL:MJ_ICONL40の呼び出し関数    */
  18. int    exitFunc()
  19. {
  20.     /*    GM_QUITで参照するexitFunc関数の復帰値    */
  21.     extern int    exitFuncRet ;
  22.  
  23.     /*    イベントループを終了させ、GUIを終了させる        */
  24.     /*    実際にはmain関数内のMMI_ExecSystem関数から抜ける    */
  25.     MMI_SetHaltFlag(TRUE) ;
  26.     exitFuncRet = NOERR ;
  27.  
  28.     return NOERR ;
  29. }
  30.  
  31. /* 座標を取得する関数 */
  32. void setPointFunc()
  33. {
  34.     static int x ;
  35.     static int y ;
  36.  
  37.     int x1 ;
  38.     int y1 ;
  39.     int button ;
  40.  
  41.     static char x2[6];
  42.     static char y2[6];
  43.  
  44.     MOS_rdpos( &button, &x1, &y1 ) ;
  45.  
  46.     if ( x1 != x )
  47.     {
  48.         intToChrFunc( x1, 4, x2, 10 ) ;
  49.         x = x1 ;
  50.         MMI_SendMessage( xMessageId, MM_SETMSG, 1, x2 ) ;
  51.         MMI_SendMessage( xMessageId, MM_SHOW,   0 ) ;
  52.     }
  53.  
  54.     if ( y1 != y )
  55.     {
  56.         intToChrFunc( y1, 4, y2, 10 ) ;
  57.         y = y1 ;
  58.         MMI_SendMessage( yMessageId, MM_SETMSG, 1, y2 ) ;
  59.         MMI_SendMessage( yMessageId, MM_SHOW,   0 ) ;
  60.     }
  61.  
  62.     return ;
  63. }
  64.  
  65. /* 変数を文字列にする関数 */
  66. int intToChrFunc( INnumber, place, RETnumber, notation )
  67.  
  68. int  INnumber ;     /* 入力値 */
  69. int  place ;        /* n桁  */
  70. char RETnumber[] ;  /* 戻り値 */
  71. int  notation ;     /* n進数 */
  72. {
  73.     char ITnumber[17] = "0123456789ABCDEF" ;
  74.     int x ; /* 一時的に保存する変数               */
  75.     int z ; /*  n進数に直す時の char ITnumber の位置を示す変数 */
  76.     int i ; /* forループ用                  */
  77.  
  78.     if( notation > 16 ) return ( -1 ) ;
  79.  
  80.     for ( i=place-1; i>=0; --i )
  81.     {
  82.         x = pow( notation, i );
  83.         z = INnumber / x ;
  84.         RETnumber[ place-1 - i ] = ITnumber[z] ;
  85.         INnumber -= ( z * x ) ;
  86.     }
  87.  
  88.     RETnumber[ place ] = 0x00 ;
  89.  
  90.     return NOERR ;
  91. }
  92.  
  93. /*  end of file  */
  94.